package cn.moieo.carcontrol.payload

import cn.moieo.carcontrol.TCPServer
import cn.moieo.carcontrol.view.Direction

class LeftRockerControl : RockerControl() {

    override fun controlMotor(
        tcpServer: TCPServer,
        direction: Direction,
        speed: Int,
        angle: Double
    ) {
        val speedByte = when (direction) {
            Direction.UP -> speed.toByte()
            Direction.DOWN -> -speed.toByte()
            else -> {
                0
            }
        }.toByte()
        val payload = PayloadUtil.buildPacket(0xF4.toByte(), byteArrayOf(speedByte))
        tcpServer.send(payload)
    }

}